﻿<%@ Page Language="C#" MasterPageFile="~/Admin/Admin.Master" AutoEventWireup="true" CodeBehind="Upload.aspx.cs" Inherits="Cms.Web.UI.Admin.Upload" %>
<%@ Register TagPrefix="neatupload" Namespace="Brettle.Web.NeatUpload" Assembly="Brettle.Web.NeatUpload" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        #queuedFiles
        {
        	margin-top: 10px;
        	margin-bottom: 10px;
        	margin-left: 4px;
        	float: left;
        }
        
        #queuedFiles span img, #queuedFiles span span
        {
        	vertical-align: middle;
        }
        
        #queuedFiles span img
        {
        	margin-top: 2px;
        	margin-bottom: 2px;
        }
        
        #ctl00_body_progressBar
        {
        	width: 520px;
        	height: 80px;
        	margin-top: -30px;
        }
        
        #overlay
        {
        	display: none;
        	position: absolute;
	        background-color: #ffffff;
            filter:alpha(opacity=70); 
            -moz-opacity: 0.70; 
            opacity: 0.70;
            width: 1px;
            height: 1px;        	
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="buttons" runat="server">
    <asp:LinkButton ID="lbCheckUpload" runat="server" OnClick="lbCheckUpload_Click" CssClass="orangeButton"><span><span><img src="Admin/Img/icons/folder_up.png" alt="" /><span><cms:LocalizedLiteral ID="llUpload" runat="server" /></span></span></span></asp:LinkButton>
    <asp:hyperlink ID="hlCancel" runat="server" CssClass="orangeButton"><span><span><img src="Admin/Img/icons/delete.png" alt="" /><span><cms:LocalizedLiteral ID="llCancel" runat="server" /></span></span></span></asp:hyperlink>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="body" runat="server">
    <asp:Literal ID="litIcon" runat="server" Visible="false" Text="Admin/Img/Icons/folder_up.png" />
    <div style="margin-bottom: 10px;"><cms:LocalizedLiteral ID="llCurrentFolder" runat="server" />: <asp:Literal ID="litFolder" runat="server" /></div>
    <neatupload:MultiFile id="multiFileId" runat="server" UseFlashIfAvailable="true" FileQueueControlID="queuedFiles">
        <a id="selectFiles" href="#" class="orangeButton"><span><span><img src="Admin/Img/icons/drive_magnify.png" alt="" /><span><cms:LocalizedLiteral ID="llSelectFiles" runat="server" /></span></span></span></a>
    </neatupload:MultiFile>
    <asp:CustomValidator id="valCustom" runat="server" ControlToValidate="multiFileId" ClientValidationFunction="validateFilenames"
        ErrorMessage="" display="None" />
    <div style="display: none; width: 500px; margin-left: 4px; margin-top: 10px;">
        <neatupload:ProgressBar id="progressBar" runat="server" inline="true" />
    </div>

    <div id="queuedFiles"></div>
    <div style="clear: both;"></div>
    
    <div id="overlay"></div>
    
    <asp:LinkButton ID="lbStartUpload" runat="server" CausesValidation="false" Text="Check" OnClick="lbStartUpload_Click" style="position: absolute; left: -10000px;" />

    <div id="overwriteWarning" style="position: absolute; left: -10000px;">
        <p><cms:LocalizedLiteral ID="llOverwriteMessage" runat="server" />:</p>
        <p><span id="lblExistingFiles"></span></p>
        <p><cms:LocalizedLiteral ID="llOverwriteQuestion" runat="server" /></p>
    </div>

    <iframe id="ifrCheckFiles" runat="server" style="position: absolute; left: -10000px;"></iframe>
    
    <script type="text/javascript">
        //<![CDATA[
        function showOverlay() {
            var queuedFiles = document.getElementById("queuedFiles");
            var overlay = document.getElementById("overlay");
            var mainBox = document.getElementById("mainBox");
            var selectFiles = document.getElementById("selectFiles");
            selectFiles.style.display = "none";
            overlay.style.left = iLib.Pos.FindX(queuedFiles) - iLib.Pos.FindX(mainBox) + "px";
            overlay.style.top = iLib.Pos.FindY(queuedFiles) - iLib.Pos.FindY(mainBox) + "px";
            overlay.style.width = queuedFiles.offsetWidth + "px";
            overlay.style.height = queuedFiles.offsetHeight + "px";
            overlay.style.display = "block";
        }
        
        function handleProgressBar() {
            var progressBar = NeatUploadPB.prototype.Bars["ctl00_body_progressBar"];
            var origDisplay = progressBar.Display;
            progressBar.Display = function () {
                var elem = document.getElementById(this.ClientID);
                elem.parentNode.style.display = "block";
                showOverlay();
                origDisplay.call(this);
            }
            progressBar.EvalOnClose = "NeatUploadMainWindow.document.getElementById('" +
		                                progressBar.ClientID + "').parentNode.style.display = \"none\"; NeatUploadMainWindow.document.getElementById(\"overlay\").style.display = \"none\"; NeatUploadMainWindow.document.getElementById(\"selectFiles\").style.display = \"\";";
        }

        // This function is called by the custom validator valCustom
        function validateFilenames(source, args) {
            // Get all selected file spans
            var spans = document.getElementById("queuedFiles").getElementsByTagName("span");
            var selectedFiles = "";
            for (var i = 0; i < spans.length; i++) {
                if (spans[i].parentNode.tagName == "SPAN") {
                    if (selectedFiles != "") {
                        selectedFiles += ",";
                    }
                    selectedFiles += spans[i].innerHTML;
                }
            }
            if (selectedFiles != "") {
                window.frames[1].checkFiles(selectedFiles);
                args.IsValid = false;
            }
            else
                __doPostBack('ctl00$body$lbStartUpload', '');
        }

        function validationCallback(status) {
            if (status == "ok") {
                __doPostBack('ctl00$body$lbStartUpload', '');
            }                
        }
        
        iLib.Dom.AddListener(window, "load", handleProgressBar);
        //]]>
    </script>
</asp:Content>
